﻿<%@ Page Language="C#" AutoEventWireup="true" validateRequest="false" CodeBehind="collaboration_pesonal_view.aspx.cs" Inherits="Ccit.Mgoa.Collaboration.collaboration_pesonal_view" %>

<%@ Register src="../USERCONTROLS/AttachUpLoad.ascx" tagname="AttachUpLoad" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>协作交流</title>
    <style type="text/css">
        td.tdSpace{width:300px; line-height:25px; text-overflow:ellipsis; white-space:nowrap;}
    </style>
    <script language="javascript" type="text/javascript" src="../script/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" type="text/javascript" src="../script/StringClass_Ext.js"></script>
    <script language="javascript" type="text/javascript">
    <!--
        var oEveryPageRecCount=5;
        
        function InitComment()
        {
            var oRecordCount=$get("hdRecordCount").value;
            if(oRecordCount>0)
            {
                var oId=$get("hdId").value;
                var oCurPageIndex = parseInt($get("lblCurPageIndex").innerText,"10");
                PageMethods.GetCollaborativeCommentInfo(oId,oCurPageIndex,oEveryPageRecCount,ClientCallBack);
            }
        }
        
        function ClientCallBack(oResult)
        {
            var objComment=JSON.parse(oResult);
            var oPageCount=objComment.PageCount;
            $get("lblTotalPage").innerText=oPageCount;
            var oRecordCount=objComment.RecordCount;
            var oComment=objComment.Comment;
            var oCommentId;
            DeleteAllRows();
            for(var i=0;i<oComment.length;i++)
            {
                oCommentId = oComment[i].Id;
                CreateRow(i,oCommentId);
            }
            doInitControl();
        }
        
        /* 移除所有行 */
        function DeleteAllRows()
        {
            var otable=document.getElementById("tbComment");
            var orow;
            var oChild;
            var oRowCount=otable.rows.length;
            for(var i=0;i<oRowCount-1;i++)
            {
                orow=otable.rows(0);
                oChild=orow.children(0);
                orow.removeChild(oChild);
                otable.deleteRow(0);
            }
        }
        
        /* 创建回复信息行 */
        function CreateRow(oLine,oCommentId)
        {
            var otable=document.getElementById("tbComment");
            
            var orow=otable.insertRow(0);
            orow.id="row_"+oCommentId;
            
            var octrl;
            var oParam="id="+oCommentId;
            var oEncodeParam=base64encode(oParam);
            var oUrl="collaboration_attach_view.aspx?"+oEncodeParam;
            var ocell=orow.insertCell();
            ocell.width="100%";
            ocell.colSpan="2";
            octrl=document.createElement("<iframe id='frmComment_"+oCommentId+"' frameborder='0' src='"+oUrl+"' width='100%'>");
            ocell.appendChild(octrl);
        }
        
        /* 转到某页 */
        function GoToPage(oType)
        {
            var oPageCount=parseInt($get("lblTotalPage").innerText,"10");
            var oCurPageIndex=parseInt($get("lblCurPageIndex").innerText,"10");
            if(oType=="first")
            {
                $get("lblCurPageIndex").innerText="1";
            }
            else if(oType=="previous")
            {
                $get("lblCurPageIndex").innerText=oCurPageIndex-1;
            }
            else if(oType=="next")
            {
                $get("lblCurPageIndex").innerText=oCurPageIndex+1;
            }
            else if(oType=="last")
            {
                $get("lblCurPageIndex").innerText=oPageCount;
            }
            else if(oType=="pagenum")
            {
                var oPageNum=$get("txtPageNum").value;
                if(oPageNum=="")
                {
                    alert("请输入转向的页码！");
                    return;
                }
                else if(!oPageNum.IsNumber())
                {
                    alert("输入的页码必须为数字！");
                    return;
                }
                else if(parseInt(oPageNum,"10")>oPageCount||parseInt(oPageNum,"10")<=0)
                {
                    alert("输入的页码不存在！");
                    return;
                }
                $get("lblCurPageIndex").innerText=oPageNum;
            }
            
            InitComment();
        }
        
        /* 控制链接可用与否 */
        function doInitControl()
        {
            var oPageCount=parseInt($get("lblTotalPage").innerText,"10");
            var oCurPageIndex=parseInt($get("lblCurPageIndex").innerText,"10");
            var oFirst=document.getElementById("haFrist");
            var oPrevious=$get("haPrevious");
            var oNext=$get("haNext");
            var oLast=$get("haLast");
            if(oCurPageIndex=="1")
            {
                oFirst.removeAttribute("href",true);
                oPrevious.removeAttribute("href",true);
                if(oPageCount=="1")
                {
                    oNext.removeAttribute("href",true);
                    oLast.removeAttribute("href",true);
                }
                else
                {
                    oNext.setAttribute("href","javascript:GoToPage('next')");
                    oLast.setAttribute("href","javascript:GoToPage('last')");
                }
            }
            else if(oCurPageIndex==oPageCount)
            {
                oNext.removeAttribute("href",true);
                oLast.removeAttribute("href",true);
                if(oPageCount=="1")
                {
                    oFirst.removeAttribute("href",true);
                    oPrevious.removeAttribute("href",true);
                }
                else
                {
                    oFirst.setAttribute("href","javascript:GoToPage('first')");
                    oPrevious.setAttribute("href","javascript:GoToPage('previous')");
                }
            }
            else
            {
                oFirst.setAttribute("href","javascript:GoToPage('first')");
                oPrevious.setAttribute("href","javascript:GoToPage('previous')");
                oNext.setAttribute("href","javascript:GoToPage('next')");
                oLast.setAttribute("href","javascript:GoToPage('last')");
            }
        }
                
        /* 回复 */
        function doAppear()
        {
            var oContent=jQuery.trim($get("txtWriteBackContent").value);
            if(oContent=="")
            {
                alert("请输入回复信息！");
                return;
            }
            __doPostBack("lnkAppear","");
        }
        
        /* 清空回复信息 */
        function doReset()
        {
            $get("txtWriteBackContent").innerText="";
            ClearShowAttaches();
        }
    //-->
    </script>
    
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
        <input type="hidden" id="hdId" runat="server" />
        <input type="hidden" id="hdRecordCount" runat="server" />
        <asp:LinkButton ID="lnkAppear" runat="server" onclick="lnkAppear_Click"></asp:LinkButton>
        <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server"></asp:ScriptManager>
        <table border="0" cellpadding="0" cellspacing="0" align="center" width="98%" class="tbToolbar">
            <tr>
                <td align="left">
                    <div class="tbSeparator"></div>
                </td>
                <td align="left" class="titlebar" style="width:100%">
                    <nobr>
                        协作空间-协作交流
                    </nobr>
                </td>
                <td align="right">
                    <div class="tbSeparatorEnd"></div>
                </td>
                <td align="right">
                    <div class="tbSeparatorEnd"></div>
                </td>
            </tr>
        </table>
        <table border="0" cellpadding="0" cellspacing="0" align="center" width="98%" class="tableborder">
            <tr>
                <td width="100%" align="center">
                    <asp:Panel runat="server" ID="paneTitle" GroupingText="协作主题" Width="98%">
                        <table border="0" cellpadding="0" id="tbCommentInfo" cellspacing="0" align="center" width="98%">
                            <tr>
                                <td width="100%" align="center">
                                    <iframe id="frmComment" frameborder="0" width="100%"></iframe>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr runat="server" id="trSplit1">
                <td width="100%" align="center">&nbsp;</td>
            </tr>
            <tr runat="server" id="trComment">
                <td width="100%" align="center">
                    <asp:Panel runat="server" ID="Panel1" GroupingText="交流讨论" Width="98%">
                        <table border="0" id="tbComment" cellpadding="0" cellspacing="0" runat="server" width="98%" align="center">
                            <tr>
                                <td id="tdPageInfo" align="left" runat="server" width="40%" class="pformright">
                                当前第<asp:Label runat="server" ID="lblCurPageIndex" Text="1"></asp:Label>页/共<asp:Label runat="server" ID="lblTotalPage" Text="1"></asp:Label>页</td>
                                <td id="Td1" runat="server" align="right" width="60%" class="pformright">
                                    <a id="haFrist" href="javascript:GoToPage('first')" runat="server" class="linktext"><img alt="" src="../images/toolbar/pages_first.gif" /></a>
                                    <a id="haPrevious" href="javascript:GoToPage('previous')" runat="server" class="linktext"><img alt="" src="../images/toolbar/pages_previous.gif" /></a>
                                    <a id="haNext" href="javascript:GoToPage('next')" runat="server" class="linktext"><img alt="" src="../images/toolbar/pages_next.gif" /></a>
                                    <a id="haLast" href="javascript:GoToPage('last')" runat="server" class="linktext"><img alt="" src="../images/toolbar/pages_last.gif" /></a>
                                    <a id="haGo" href="javascript:GoToPage('pagenum')" runat="server" class="linktext"><img alt="" src="../images/toolbar/go.gif" /></a>
                                    <input type="text" id="txtPageNum" runat="server" class="input" style="width:30px" />页
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr runat="server" id="trSplit2">
                <td width="100%" align="center">&nbsp;</td>
            </tr>
            <tr runat="server" id="trWriteBack">
                <td width="100%" align="center">
                    <asp:Panel runat="server" ID="Panel2" GroupingText="回复" Width="98%">
                        <table border="0" cellpadding="0" cellspacing="0" align="center" width="98%">
                            <tr>
                                <td align="right" style="border-left:1px solid" class="pformleft" width="15%">
                                    内容：
                                </td>
                                <td class="pformrightline" align="center">
                                    <asp:TextBox ID="txtWriteBackContent" CssClass="inputarea" runat="server" TextMode="MultiLine" Rows="4" Width="98%"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" style="border-left:1px solid" class="pformleft" width="15%">
                                    附件：
                                </td>
                                <td class="pformrightline" width="75%">
                                    <a href="javascript:OpenUpLoadPage()">上传附件</a>
                                    <uc1:AttachUpLoad ID="appearAttach" ShowStyle="1" runat="server" />
                                </td>
                            </tr>
                            <tr><td class="pformright" colspan="2">&nbsp;</td></tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr id="trAppear" runat="server">
                <td align="center" class="pformstrip">
                    <input type="button" id="btnSubmit" onclick="doAppear()" runat="server" value="发表" class="button" />&nbsp;&nbsp;
                    <input type="button" id="btnReset" runat="server" onclick="doReset()" value="清空" class="button" />&nbsp;&nbsp;
                    <input type="button" id="btnClose" onclick="javascript:window.close();" runat="server" value="关闭" class="button" />
                </td>
            </tr>
        </table>
        <br />
        <br />
        <br />
    </ccit:ActionForm>
    
    <script language="javascript" type="text/javascript">
        $(document).ready(function(){
	            var oCommentId=document.getElementById("hdId").value;
                var oParam="id="+oCommentId;
                var oEncodeParam=base64encode(oParam);
                frames["frmComment"].document.location.href="collaboration_pesonal_info.aspx?"+oEncodeParam;
                InitComment();
            }
        );
    </script>
</body>
</html>